import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/base/JVxeTable/types';
import { getWeekMonthQuarterYear } from '/@/utils';

interface vexTableColumn extends BasicColumn {
  formatter?: (params: { cellValue: any; row: any; column: any }) => any;
}

//列表数据
export const columns: vexTableColumn[] = [
  {
    title: '立项名称',
    dataIndex: 'projectName',
    align: 'left',
  },
  {
    title: '项目责任主体',
    dataIndex: 'projectCode',
    align: 'left',
  },
  {
    title: '项目类别',
    dataIndex: 'projectType_dictText',
    align: 'left',
  },
  {
    title: '版本号',
    dataIndex: 'visionNo',
  },
  {
    title: '立项总金额',
    dataIndex: 'projectAmountSummary',
    align: 'right',
  },
  {
    title: '流程状态',
    dataIndex: 'processStatus',
    align: 'left',
    formatter: ({ cellValue }) => {
      switch (cellValue) {
        case 'COMPLETE':
          return '审批通过';
        case 'TERMINATION':
          return '审批终止';
        case 'RUNNING':
          return '审批中';
        case 'DRAFT':
          return '待提交';
        default:
          return '';
      }
    },
  },
];

//子表表格配置
export const projectProposalPreparationDetailCopyColumns: JVxeColumn[] = [
  {
    title: '测试',
    key: 'test',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '关联键',
    key: 'project_proposal_preparation_id',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
]
  export const projectAmountDetailCopyColumns: JVxeColumn[] = [
  {
    title: '立项编号',
    key: 'projectId',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '立项名称',
    key: 'projectName',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '项目编码',
    key: 'itemCode',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '项目名称',
    key: 'itemName',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '父级编码',
    key: 'parentCode',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '清单类型',
    key: 'listType',
    type: JVxeTypes.select,
    options: [],
    dictCode: 'list_type',
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '单位',
    key: 'unit',
    type: JVxeTypes.select,
    options: [],
    dictCode: '',
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '送审数量',
    key: 'submitQuantity',
    type: JVxeTypes.inputNumber,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: false }, { pattern: 'n', message: '${title}格式不正确' }],
  },
  {
    title: '送审单价',
    key: 'submitUnitPrice',
    type: JVxeTypes.inputNumber,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: false }, { pattern: 'n', message: '${title}格式不正确' }],
  },
  {
    title: '送审合价',
    key: 'submitTotalPrice',
    type: JVxeTypes.inputNumber,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: false }, { pattern: 'n', message: '${title}格式不正确' }],
  },
  {
    title: '审核数量',
    key: 'auditQuantity',
    type: JVxeTypes.inputNumber,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: false }, { pattern: 'n', message: '${title}格式不正确' }],
  },
  {
    title: '审核单价',
    key: 'auditUnitPrice',
    type: JVxeTypes.inputNumber,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: false }, { pattern: 'n', message: '${title}格式不正确' }],
  },
  {
    title: '审核合价',
    key: 'auditTotalPrice',
    type: JVxeTypes.inputNumber,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: false }, { pattern: 'n', message: '${title}格式不正确' }],
  },
  {
    title: '增减金额',
    key: 'amountChange',
    type: JVxeTypes.inputNumber,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '审核意见',
    key: 'auditComment',
    type: JVxeTypes.textarea,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '总表项目编码',
    key: 'projectProposalPreparationId',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectName: { title: '立项名称	', order: 0, view: 'text', type: 'string' },
  projectCode: { title: '立项编码	', order: 1, view: 'text', type: 'string' },
  projectType: { title: '项目类别', order: 3, view: 'list', type: 'string', dictCode: 'project' },
  visionNo: { title: '版本号', order: 4, view: 'text', type: 'string' },
  responsibleEntity: { title: '项目责任主体', order: 8, view: 'sel_depart', type: 'string' },
  projectAmountSummary: { title: '立项总金额', order: 15, view: 'number', type: 'number' },
  processStatus: { title: '流程状态', order: 25, view: 'text', type: 'string' },
  //子表高级查询
  projectAmountDetail: {
    title: '立项金额附表',
    view: 'table',
    fields: {
      projectId: { title: '立项编号', order: 0, view: 'text', type: 'string' },
      projectName: { title: '立项名称', order: 1, view: 'text', type: 'string' },
      itemCode: { title: '项目编码', order: 2, view: 'text', type: 'string' },
      itemName: { title: '项目名称', order: 3, view: 'text', type: 'string' },
      parentCode: { title: '父级编码', order: 4, view: 'text', type: 'string' },
      listType: { title: '清单类型', order: 5, view: 'list', type: 'string', dictCode: 'list_type' },
      unit: { title: '单位', order: 6, view: 'list', type: 'string', dictCode: '' },
      submitQuantity: { title: '送审数量', order: 7, view: 'number', type: 'number' },
      submitUnitPrice: { title: '送审单价', order: 8, view: 'number', type: 'number' },
      submitTotalPrice: { title: '送审合价', order: 9, view: 'number', type: 'number' },
      auditQuantity: { title: '审核数量', order: 10, view: 'number', type: 'number' },
      auditUnitPrice: { title: '审核单价', order: 11, view: 'number', type: 'number' },
      auditTotalPrice: { title: '审核合价', order: 12, view: 'number', type: 'number' },
      amountChange: { title: '增减金额', order: 13, view: 'number', type: 'number' },
      auditComment: { title: '审核意见', order: 14, view: 'textarea', type: 'string' },
      projectProposalPreparationId: { title: '总表项目编码', order: 15, view: 'text', type: 'string' },
    },
  },
};

export const approvalRunTaskBo = {
  task_instance_id: '',
  command_id: '',
  command_type: '',
  task_comment: '',
  transfer_user_id: '',
  revoke_task_id: '',
  endorsement_user_id_list: '',
  notice_user_id_list: '',
  roll_back_node_id: '',
  attachment_id: '',
  sureMessage: '',
  optional_node_assignee: {},
};
